package com.yj.spring725;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;

/**
 * Description:
 * Date: 2024-07-25
 * Time: 11:22
 */
@Controller
@ResponseBody
public class ResponseController {
    @RequestMapping("/resp1")
    public Object resp1() {
        return "/index.html";
    }

    @RequestMapping("/resp2")
    public String resp2() {
        return "<h1>Hello,html</h1>";
    }

    @RequestMapping("resp3")
    public HashMap<Integer,String> resp3() {
        HashMap<Integer,String> map = new HashMap<>();
        map.put(1,"Hello");
        map.put(2,"JSON");
        return map;
    }

    @RequestMapping("resp4")
    public String resp4(HttpServletResponse response) {
        response.setStatus(404);
        return "状态码设置成功";
    }
}
